From a44d3598295fdd2fc742bb7b36695f82ddb77c36 Mon Sep 17 00:00:00 2001 From: "akw27@arcadians.cl.cam.ac.uk" Date: Mon, 14 Mar 2005 09:03:44 +0000 Subject: [PATCH] bitkeeper revision 1.1236.30.2 (423553705lFIxda6xBfLOruUqofkAQ) xcs control channel cleanup fixes from rick cox. Signed-off-by: andrew.warfield@cl.cam.ac.uk --- tools/xcs/xcs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/xcs/xcs.c b/tools/xcs/xcs.c index 8539d20dfc..08085d4352 100644 --- a/tools/xcs/xcs.c +++ b/tools/xcs/xcs.c @@ -97,7 +97,7 @@ static void map_dom_to_port(u32 dom, int port) exit(1); } - for (; dom_port_map_size < dom + 10; dom_port_map_size++) { + for (; dom_port_map_size < dom + 256; dom_port_map_size++) { dom_port_map[dom_port_map_size] = -1; } } @@ -123,7 +123,7 @@ static control_channel_t *add_interface(u32 dom, int local_port, control_channel_t *cc=NULL, *oldcc; int ret; - if (cc_list[dom_to_port(dom)] != NULL) + if ((dom_to_port(dom) >= 0) && (cc_list[dom_to_port(dom)] != NULL)) { return(cc_list[dom_to_port(dom)]); } @@ -155,10 +155,13 @@ static control_channel_t *add_interface(u32 dom, int local_port, if ((oldcc->remote_dom != cc->remote_dom) || (oldcc->remote_port != cc->remote_port)) { - DPRINTF("CC conflict! (port: %d, old dom: %u, new dom: %u)\n", - cc->local_port, oldcc->remote_dom, cc->remote_dom); + DPRINTF("CC conflict! (port: %d, old dom: %u, new dom: %u, " + "old ref_count: %d)\n", + cc->local_port, oldcc->remote_dom, cc->remote_dom, + oldcc->ref_count); map_dom_to_port(oldcc->remote_dom, -1); ctrl_chan_free(cc_list[cc->local_port]); + cc_list[cc->local_port] = NULL; } } @@ -210,6 +213,8 @@ void put_interface(control_channel_t *cc) { DPRINTF("Freeing cc on port %d.\n", cc->local_port); (void)evtchn_unbind(cc->local_port); + cc_list[cc->local_port] = NULL; + map_dom_to_port(cc->remote_dom, -1); ctrl_chan_free(cc); } } -- 2.30.2